package kobetool.dshowwrapper;

/**
 * Simple video format<br>
 * width and height will be ignored if they were zeros.<br>
 * subType will be ignored if it is null.
 * @see GUID
 */
public class VideoFormat {

    private int width, height;
    private GUID subType;

    public VideoFormat(int width, int height, GUID subType) {
        this.width = width;
        this.height = height;
        this.subType = subType;
    }

    public VideoFormat(int width, int height) {
        this(width, height, null);
    }

    public VideoFormat(GUID subType) {
        this(0, 0, subType);
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    public GUID getSubType() {
        return subType;
    }

    public String toString() {
        return "VideoFormat{" +
                "width=" + width +
                ", height=" + height +
                ", subType=" + subType +
                '}';
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        VideoFormat that = (VideoFormat) o;

        if (height != that.height) return false;
        if (width != that.width) return false;
        if (!subType.equals(that.subType)) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = width;
        result = 31 * result + height;
        result = 31 * result + subType.hashCode();
        return result;
    }
}
